<template>
  <div class="app-container">
    <el-table
      v-loading="listLoading"
      :data="list"
      :border="false"
      fit
      style="width: 100%;"
    >
      <el-table-column label="ID" width="80">
        <template slot-scope="{row}">
          <span>{{ row.id }}</span>
        </template>
      </el-table-column>
      <el-table-column label="会员ID">
        <template slot-scope="{row}">
          <span>{{row.user_id}}</span>
        </template>
      </el-table-column>
      <el-table-column label="总金额">
        <template slot-scope="{row}">
          <span>{{row.total}}</span>
        </template>
      </el-table-column>
      <el-table-column label="实际金额">
        <template slot-scope="{row}">
          <span>{{row.real_total}}</span>
        </template>
      </el-table-column>
      <el-table-column label="扣除金额">
        <template slot-scope="{row}">
          <span>{{row.total - row.real_total}}</span>
        </template>
      </el-table-column>
      <el-table-column label="比例" v-if="true">
        <template slot-scope="{row}">
          <span>{{+row.amount}}%</span>
        </template>
      </el-table-column>
      <el-table-column label="佣金">
        <template slot-scope="{row}">
          <span>{{row.result_amount}}</span>
        </template>
      </el-table-column>
      <el-table-column label="订单" width="150">
        <template slot-scope="{row}">
          <span @click="showOrder(row)" class="l">
            <span class="link">查看订单</span>
            <!--<span class="text">请选择对应时间</span>-->
          </span>
        </template>
      </el-table-column>
      <el-table-column label="上传时间" width="160">
        <template slot-scope="{row:{create_time}}">
          <i class="el-icon-time" />
          <span style="margin-left: 5px">{{ create_time | timeFilter }}</span>
        </template>
      </el-table-column>
      <el-table-column label="更新时间" width="160">
        <template slot-scope="{row}">
          <i class="el-icon-time" />
          <span style="margin-left: 5px">{{ row.update_time | timeFilter }}</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import waves from '@/directive/waves'
import api from '@/api'
import { parseTime } from '@/utils'

export default {
  name: 'MemberProfit',
  directives: { waves },
  filters: {
    timeFilter(time) {
      return time ? parseTime(time, '{m}-{d} {h}:{i}') : ''
    }
  },
  data() {
    return {
      listLoading: false,
      list: []
    }
  },
  created() {
  },
  mounted() {
    this.getList()
  },
  methods: {
    /**
     * 获取数据列表
     */
    getList() {
      this.listLoading = true
      api.member.projectList().then(response => {
        const { data } = response
        this.list = data.list
      }).finally(() => {
        this.listLoading = false
      })
    },
    showOrder(item) {
      console.log(item.user_id, item.create_time)
      // this.$router.push(`/order/list?team_id=${item.user_id}&create_time=${item.create_time}`)
      // 根据月奖id来操作
      this.$router.push(`/order/list?month_id=${item.id}&x=1`)
    }
  }
}
</script>
<style scoped>
.l {
  cursor: pointer;
  display: flex;
  flex-direction: column;
.link {
  color: #000000;
  text-decoration: underline;
}
.text {
  font-size: 10px;
  color: #999999;
}
}
</style>
